package cn.loioi.multi.mysql.been;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import cn.loioi.multi.mysql.model.SysUser;
import tk.mybatis.mapper.common.Mapper;

public interface SysUserMapper extends Mapper<SysUser> {
	@ResultType(String.class)
	@Select("SELECT `password` FROM sys_user WHERE account = #{account}")
	String login(@Param("account") String account);

	@ResultType(Map.class)
	@Select("SELECT sys_role.`name`,sys_role.id,sys_user_role.role AS `checked` FROM sys_role LEFT JOIN sys_user_role ON sys_user_role.role = sys_role.id AND sys_user_role.account = #{account}")
	List<Map<String, Object>> selectUserRole(@Param("account") String account);

	@Delete("DELETE FROM `sys_user_role` WHERE account = #{account}")
	int deleteUserRole(@Param("account") String account);

	int insertUserRole(@Param("account") String account, @Param("ids") Integer[] ids);
}